<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .big {
        font-size: 30px;
        font-weight: 900;
      }
      .color-red {
        color: red;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <h3>class</h3>
      <!-- <p v-bind:class="show && 'big'">hello world!</p> -->

      <!-- class做了专门的增强，允许我们写对象，key表示类名，value表示变量或者表达式 -->
      <!-- <p :class="{big: show, 'color-red': active === 2}">hello world!</p> -->

      <!-- class和:class是可以一起用的 -->
      <p :class="style" class="abc">hello world!</p>
    </div>

    <script src="../Vue.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {
          show: true,
          active: 2,
        },
        computed: {
          style() {
            return { big: this.show, "color-red": this.active === 2 };
          },
        },
        mounted() {
          setTimeout(() => {
            this.active = 4;
          }, 2000);
        },
      });
    </script>
  </body>
</html>
